var mysql = require("./mysql");

var handler = {};

handler["getAllTableName"] = function (ws, data) {
    mysql.query("select table_name name,table_comment comment from information_schema.tables  where table_schema='" + data.database + "'", data, function (result, field) {
        ws.send(JSON.stringify({code: "getAllTableName", data: result}));
    });
}

handler['getCreateTableSql'] = function (ws, data) {
    mysql.query("show create table "+data.tableName, data, function (result, field) {
        ws.send(JSON.stringify({code: "getCreateTableSql", data: result[0]["Create Table"]}));
    });
}

module.exports = {
    exec: function (ws, key, data) {
        handler[key](ws, data);
    }
}